<?php
/**
 * 死活監視
 *
 * @package  app
 * @extends  Controller
 */

class Controller_Monitor extends Controller {
	/**
	 * サーバー通信
	 *
	 * @access  public
	 * @return  Response
	 */
	public function action_server() {
		// DB
		try {
			$query = DB::select(DB::expr('COUNT(*) AS count'));
			$query -> from('itunes_song');
			$result = $query -> execute() -> as_array();
		} catch(\Database_exception $e) {
			return Response::forge('NG DB'.chr(13). $e->getMessage(), D_HTTP_UPDATE);
		}
		
		// キャッシュ
		try {
			Cache::set('monitor','server');
			Cache::get('monitor');
		} catch (\Exception $e) {
			return Response::forge('NG CACHE'.chr(13). $e->getMessage(), D_HTTP_UPDATE);
		}
				
		return Response::forge('OK', D_HTTP_UPDATE);
	}

}
